package com.dykj.fireFighting.web.base.bigdata.controller;

import com.dykj.fireFighting.api.base.bigdata.Building.entity.Building;
import com.dykj.fireFighting.api.base.bigdata.Building.service.IBuildingService;
import com.dykj.fireFighting.common.core.annotation.AutoLog;
import com.dykj.fireFighting.common.core.api.CommonResult;
import com.dykj.fireFighting.common.core.exception.BaseException;
import com.dykj.fireFighting.common.core.vo.LoginUserVo;
import com.dykj.fireFighting.web.base.shiro.ShiroUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@Slf4j
@Api(value = "大数据楼栋", tags = {"大数据楼栋"})
@RestController
@RequestMapping("bigdata/building")
public class BigDataBuildingController {
    @DubboReference
    private IBuildingService buildingService;
    @AutoLog(value = "大数据页面-楼栋信息")
    @ApiOperation(value = "大数据页面-楼栋信息", notes = "大数据页面-楼栋信息")
    @GetMapping("/list")
    public CommonResult list() {
        List<Building> list=buildingService.getBuildList(getEnterpriseId());
        return CommonResult.success(list);
    }
    /**
     * 获取单位id
     * @return String
     */
    public String getEnterpriseId() {
        try {
            return Long.toString(ShiroUtil.getUser().getEnterpriseId());
        } catch (NullPointerException e) {
            e.printStackTrace();
            throw new BaseException("请登录系统");
        }
    }
}
